using System.ComponentModel.DataAnnotations;

namespace SG3L_RAG.Application.DTOs;

/// <summary>
/// 登录请求DTO
/// </summary>
public class LoginDto
{
    [Required(ErrorMessage = "用户名不能为空")]
    public string Username { get; set; } = string.Empty;

    [Required(ErrorMessage = "密码不能为空")]
    public string Password { get; set; } = string.Empty;
}

/// <summary>
/// 登录响应DTO
/// </summary>
public class LoginResponseDto
{
    public string Token { get; set; } = string.Empty;
    public string TokenType { get; set; } = "Bearer";
    public DateTime ExpiresAt { get; set; }
    public UserInfoDto User { get; set; } = null!;
}

/// <summary>
/// 注册请求DTO
/// </summary>
public class RegisterDto
{
    [Required(ErrorMessage = "用户名不能为空")]
    [StringLength(50, MinimumLength = 3, ErrorMessage = "用户名长度必须在3-50个字符之间")]
    public string Username { get; set; } = string.Empty;

    [Required(ErrorMessage = "密码不能为空")]
    [StringLength(100, MinimumLength = 6, ErrorMessage = "密码长度必须在6-100个字符之间")]
    public string Password { get; set; } = string.Empty;

    public string Email { get; set; } = string.Empty;

    public string PhoneNumber { get; set; } = string.Empty;

    public string Role { get; set; } = "user";
}

/// <summary>
/// 用户信息DTO
/// </summary>
public class UserInfoDto
{
    public Guid Id { get; set; }
    public string Username { get; set; } = string.Empty;
    public string Email { get; set; } = string.Empty;
    public string PhoneNumber { get; set; } = string.Empty;
    public string Role { get; set; } = string.Empty;
    public string? Avatar { get; set; } = string.Empty; // 添加Avatar字段
    public DateTime CreatedAt { get; set; }
}

/// <summary>
/// JWT配置
/// </summary>
public class JwtOptions
{
    public const string SectionName = "Jwt";
    
    public string Key { get; set; } = string.Empty;
    public string Issuer { get; set; } = string.Empty;
    public string Audience { get; set; } = string.Empty;
    public int ExpiryInHours { get; set; } = 24;
}

/// <summary>
/// 刷新Token请求DTO
/// </summary>
public class RefreshTokenDto
{
    [Required(ErrorMessage = "Token不能为空")]
    public string Token { get; set; } = string.Empty;
}

/// <summary>
/// Token验证响应DTO
/// </summary>
public class TokenValidationResponseDto
{
    public bool IsValid { get; set; }
    public UserInfoDto? User { get; set; }
    public string? ErrorMessage { get; set; }
}

/// <summary>
/// 验证身份信息请求DTO（用于忘记密码流程）
/// </summary>
public class VerifyIdentityDto
{
    [Required(ErrorMessage = "用户名不能为空")]
    public string Username { get; set; } = string.Empty;
    
    public string? Email { get; set; }
    
    public string? PhoneNumber { get; set; }
}

/// <summary>
/// 重置密码请求DTO（用于忘记密码流程）
/// </summary>
public class ResetPasswordDto
{
    [Required(ErrorMessage = "用户ID不能为空")]
    public Guid UserId { get; set; }
    
    [Required(ErrorMessage = "新密码不能为空")]
    [StringLength(100, MinimumLength = 6, ErrorMessage = "密码长度必须在6-100个字符之间")]
    public string NewPassword { get; set; } = string.Empty;
    
    [Required(ErrorMessage = "验证码不能为空")]
    public string VerifyCode { get; set; } = string.Empty;
}
